//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.statistic;

import java.awt.*;
import javax.swing.*;
import org.jpgolay.gui.fixed.LabelAndDateButton;
import org.jpgolay.gui.fixed.LabelAndLabel;

public class StatisticsWelcomePiecesGUI extends JPanel {

    public StatisticsWelcomePiecesGUI(LayoutManager layout, boolean isDoubleBuffered) {
        super(layout, isDoubleBuffered);
        jPanel = null;
        statTitle = null;
        statPeriod = null;
        statInfo1 = null;
        statInfo2 = null;
        statInfo3 = null;
        statInfo4 = null;
        statInfo5 = null;
        initialize();
    }

    public StatisticsWelcomePiecesGUI(LayoutManager layout) {
        super(layout);
        jPanel = null;
        statTitle = null;
        statPeriod = null;
        statInfo1 = null;
        statInfo2 = null;
        statInfo3 = null;
        statInfo4 = null;
        statInfo5 = null;
        initialize();
    }

    public StatisticsWelcomePiecesGUI(boolean isDoubleBuffered) {
        super(isDoubleBuffered);
        jPanel = null;
        statTitle = null;
        statPeriod = null;
        statInfo1 = null;
        statInfo2 = null;
        statInfo3 = null;
        statInfo4 = null;
        statInfo5 = null;
        initialize();
    }

    public StatisticsWelcomePiecesGUI() {
        jPanel = null;
        statTitle = null;
        statPeriod = null;
        statInfo1 = null;
        statInfo2 = null;
        statInfo3 = null;
        statInfo4 = null;
        statInfo5 = null;
        initialize();
    }

    private void initialize() {
        green = new ImageIcon(getClass().getResource("/org/jpgolay/me/images/vert.png"));
        orange = new ImageIcon(getClass().getResource("/org/jpgolay/me/images/orange.png"));
        red = new ImageIcon(getClass().getResource("/org/jpgolay/me/images/rouge.png"));
        setLayout(new BorderLayout());
        setSize(312, 195);
        setBorder(BorderFactory.createBevelBorder(1));
        add(getJPanel(), "Center");
    }

    private JPanel getJPanel() {
        if (jPanel == null) {
            GridLayout gridLayout1 = new GridLayout();
            jPanel = new JPanel();
            jPanel.setLayout(gridLayout1);
            gridLayout1.setRows(7);
            gridLayout1.setColumns(1);
            jPanel.add(getStatTitle(), null);
            jPanel.add(getStatPeriod(), null);
            jPanel.add(getStatInfo1(), null);
            jPanel.add(getStatInfo2(), null);
            jPanel.add(getStatInfo3(), null);
            jPanel.add(getStatInfo4(), null);
            jPanel.add(getStatInfo5(), null);
        }
        return jPanel;
    }

    private LabelAndDateButton getStatTitle() {
        if (statTitle == null) {
            statTitle = new LabelAndDateButton();
            statTitle.setLabelLeft("GESTION COMMERCIAL   -   ETAT  >>>");
            statTitle.getButtonRight().setIcon(green);
            statTitle.getButtonRight().setToolTipText("vert = OK, orange = ATTENTION, rouge = MESURES URGENTES");
        }
        return statTitle;
    }

    private LabelAndDateButton getStatPeriod() {
        if (statPeriod == null) {
            statPeriod = new LabelAndDateButton();
        }
        return statPeriod;
    }

    private LabelAndLabel getStatInfo1() {
        if (statInfo1 == null) {
            statInfo1 = new LabelAndLabel();
        }
        return statInfo1;
    }

    private LabelAndLabel getStatInfo2() {
        if (statInfo2 == null) {
            statInfo2 = new LabelAndLabel();
        }
        return statInfo2;
    }

    private LabelAndLabel getStatInfo3() {
        if (statInfo3 == null) {
            statInfo3 = new LabelAndLabel();
        }
        return statInfo3;
    }

    private LabelAndLabel getStatInfo4() {
        if (statInfo4 == null) {
            statInfo4 = new LabelAndLabel();
        }
        return statInfo4;
    }

    private LabelAndLabel getStatInfo5() {
        if (statInfo5 == null) {
            statInfo5 = new LabelAndLabel();
        }
        return statInfo5;
    }

    public LabelAndDateButton getStatTitlePanel() {
        return getStatTitle();
    }

    public LabelAndDateButton getStatPeriodDate() {
        return getStatPeriod();
    }

    public LabelAndLabel getStatInfoLine1() {
        return getStatInfo1();
    }

    public LabelAndLabel getStatInfoLine2() {
        return getStatInfo2();
    }

    public LabelAndLabel getStatInfoLine3() {
        return getStatInfo3();
    }

    public LabelAndLabel getStatInfoLine4() {
        return getStatInfo4();
    }

    public LabelAndLabel getStatInfoLine5() {
        return getStatInfo5();
    }

    public void setStatusColor(int color) {
        switch (color) {
            case 0: // '\0'
                getStatTitle().getButtonRight().setIcon(green);
                break;

            case 1: // '\001'
                getStatTitle().getButtonRight().setIcon(orange);
                break;

            case 2: // '\002'
                getStatTitle().getButtonRight().setIcon(red);
                break;
        }
    }
    private JPanel jPanel;
    private LabelAndDateButton statTitle;
    private LabelAndDateButton statPeriod;
    private LabelAndLabel statInfo1;
    private LabelAndLabel statInfo2;
    private LabelAndLabel statInfo3;
    private LabelAndLabel statInfo4;
    private LabelAndLabel statInfo5;
    private Icon green;
    private Icon orange;
    private Icon red;
    public static final int GREEN = 0;
    public static final int ORANGE = 1;
    public static final int RED = 2;
}
